/*
 * Copyright 2011 J. Auer, J. Andert, F.-J. Jendrusch, U. Celebi
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.fuberlin.replication.application.android.communication;

import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import de.fuberlin.replication.application.Synchronizable;
import de.fuberlin.replication.application.android.Rotatable;
import de.fuberlin.replication.communication.Communication;

/**
 * Android-specific communication helper interface.
 */
public interface CommunicationHelper extends Rotatable {
	/**
	 * Activity result callback hook.
	 * 
	 * @param requestCode the integer request code originally supplied to
	 *            {@link Activity#startActivityForResult(Intent, int)}.
	 * @param resultCode the integer result code returned by the child activity through its
	 *            {@link Activity#setResult(int)} or {@link Activity#setResult(int, Intent)}.
	 * @param data an Intent, which can return result data to the caller.
	 * @see Activity#startActivityForResult(Intent, int)
	 * @see Activity#setResult(int)
	 * @see Activity#setResult(int, Intent)
	 */
	void onActivityResult(int requestCode, int resultCode, Intent data);

	/**
	 * Create dialog callback hook.
	 * 
	 * @param id the id of the dialog.
	 * @param args the dialog arguments provided to {@link Activity#showDialog(int, Bundle)}.
	 * @return the dialog or null, if the given dialog id is unknown.
	 * @see Activity#showDialog(int, Bundle)
	 */
	Dialog onCreateDialog(int id, Bundle args);

	/**
	 * Prepare dialog callback hook.
	 * 
	 * @param id the id of the managed dialog.
	 * @param dialog the dialog.
	 * @param args the dialog arguments provided to {@link Activity#showDialog(int, Bundle)}.
	 * @see Activity#showDialog(int, Bundle)
	 */
	void onPrepareDialog(int id, Dialog dialog, Bundle args);

	/**
	 * Returns the communication implementation.
	 * 
	 * @return the communication implementation.
	 */
	Communication getCommunication();

	/**
	 * Synchronization start callback hook.
	 * 
	 * @see Synchronizable#onSynchronizationStart()
	 */
	void onSynchronizationStart();

	/**
	 * Synchronization exception callback hook.
	 * 
	 * @param e the exception.
	 * @see Synchronizable#onSynchronizationException(Exception)
	 */
	void onSynchronizationException(Exception e);

	/**
	 * Synchronization stop callback hook.
	 * 
	 * @see Synchronizable#onSynchronizationStop()
	 */
	void onSynchronizationStop();
}